<?php
class control_upload extends core_action{
	public $upload;
	
	function __construct(){
		$this->upload = new Qupload();
		$this->upload->savePath = core_lib_constant::UPLOAD_PATH.date('Ym/');
	}
	
	function index(){
		$p = intval($_REQUEST['p']);
		if($_POST){
			$this->upload->thumb = true;
			$this->upload->thumbPrefix = '80_,200_,500_';
			$this->upload->thumbMaxWidth = '80,200,500';
			$this->upload->thumbMaxHeight = '80,200,500';
			$file = $this->upload->uploadOne($_FILES['imgFile']);
			$file = $file[0];
			echo '<span>上传中...</span>
			<script>parent.document.getElementById("editor_content_iu_t").value=1;
			parent.document.getElementById("editor_content_iu").value="'.$file['savepath'].$file['savename'].'";
			parent.document.getElementById("editor_content_iu_bn").value="'.$file['name'].'";
			location.href="/index.php?ac=upload";
			</script>';
			exit;
		}
		echo '<style type="text/css">*{margin:0; padding:0;}</style>
			<form action="'.Qtpl::createUrl('upload', 'index').'" method="post" enctype="multipart/form-data">
				<input type="hidden" name="p" value="'.$p.'" />
				<a>上传：</a><input type="file" id="imgFile" name="imgFile" />
				<input type="submit" class="subbtn" value="上传" />
			</form>';
		
	}
	
}